package controllers

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"purchase-mall/services"
	"purchase-mall/services/service"
)

// IpListByLokiHandler 获取ip请求列表
func IpListByLokiHandler(c *gin.Context) {
	var ipListSearch service.IpListSearch
	err := c.ShouldBindJSON(&ipListSearch)
	if err != nil {
		zap.L().Error("get ipList params failed", zap.Error(err))
	}

	if ipListSearch.PageNum == 0 {
		ipListSearch.PageNum = 1
	}

	if ipListSearch.PageSize == 0 {
		ipListSearch.PageSize = 10
	}

	data, err := services.GetIpListService(&ipListSearch)
	if err != nil {
		zap.L().Error("services.GetIpListService() failed", zap.Error(err))
		ResponseError(c, CodeServerBusy)
		return
	}
	ResponseSuccess(c, data)
}
